#include("../common/header.html")
<body>
	<div id="container" style="background-color:#ffffff;top:0vh;height:100vh;">
	</div>
</body>
<script>
	$(document)[0].title="提现记录";
	$(document).ready(function (){
		var page=1;
		var html='';
		var length=[];
		$.ajax({
			type: "GET",
			url: "#(ctx)/wap/member/cash",
			data:{'act':'ajaxpage','page':page},
			dataType: "json",
			success: function(data){
				if(data.length>0){
					$("#container").html('');
					$.each(data, function(idx, obj) {
						html = `<div class="cash between">
									<div class="cahsL flex">
										<div class="cashUser column">
											<div class="cashName" style="max-width:30vw;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">`+obj.nickname+`</div>
											<div class="cashTime">`+obj.createtime+`</div>
										</div>
									</div>
									<div class="cahsR"> -`+obj.money+`</div>
								</div>`;
						$("#container").append(html);
					});
					page++;
				}
				for (var i in data) {
					length.push(data[i])
				}

				if(length.length==0){
						$("#container").append('<p style="margin-top:5vw;text-align:center">暂无数据</p>');
				}
			}
		});

        var nScrollHight = 0; //滚动距离总长(注意不是滚动条的长度)
        var nScrollTop = 0;   //滚动到的当前位置
        var nDivHight = $("#container").height();
        
        $("#container").scroll(function(){
        	nScrollHight = $(this)[0].scrollHeight;
        	nScrollTop = $(this)[0].scrollTop;
        	if(nScrollTop + nDivHight >= nScrollHight){
        		// alert("滚动条到底部了");
        		console.log("到底了");

        		$.ajax({
					type: "GET",
					url: "#(ctx)/wap/member/cash",
					data:{'act':'ajaxpage','page':page},
					dataType: "json",
					success: function(data){
						if(data.length>0){
        					$.each(data, function(idx, obj) {
								html = `<div class="cash between">
											<div class="cahsL flex">
												<div class="cashUser column">
													<div class="cashName">`+obj.nickname+`</div>
													<div class="cashTime">`+obj.createtime+`</div>
												</div>
											</div>
											<div class="cahsR"> -`+obj.money+`</div>
										</div>`;
								$("#container").append(html);
							});
							page++;
						}
					}
				});
        	}

        });
    });
</script>
</html>